package com.zzyl.mapper;

import com.github.pagehelper.Page;
import com.zzyl.entity.NursingPlan;
import com.zzyl.vo.NursingPlanVo;
import io.swagger.v3.oas.annotations.Operation;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Service;

import java.util.List;

@Mapper
public interface NursingPlanMapper {

    @Options(useGeneratedKeys = true, keyProperty = "id") //返回新增的主键id
    Integer insert( NursingPlan nursingPlan);

    void update(NursingPlan nursingPlan);

    void deleteById(Long id);

    NursingPlan selectById(Long id);

    List<NursingPlan> selectAll();

    Page<NursingPlanVo> pageQuery(@Param(value = "name")String name, @Param(value = "status")Integer status);

    /**
     * 判断名称是否重复
     * @param planName
     * @return
     */
    @Select("select count(*) from nursing_plan where plan_name = #{planName}")
    Integer selectNameCount(String planName);
    /**
     * 判断名称是否重复排除当前id
     * @param planName
     * @return
     */
    @Select("select count(*) from nursing_plan where plan_name = #{planName} and id != #{id}")
    Integer selectNameCountExcludeId(@Param(value = "planName")String planName,@Param(value = "id")Long id);

    Integer selectCountById(Long id);


    @Update("update nursing_plan set status = #{status} where id = #{id}")
    void updateStatus(@Param(value = "id")Long id, @Param(value = "status")Integer status);


}